//
//  TKYAllSafetyMessageController.m
//  StationHouseHelper
//
//  Created by apple on 2018/7/9.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYAllSafetyMessageController.h"
#import "TKYSafetyCell.h"
@interface TKYAllSafetyMessageController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong)BaseTabelView *tabelV;


@end

@implementation TKYAllSafetyMessageController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"====%@", self.str);
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(click:) name:@"name" object:nil];
    
    [self setupUI];
    // Do any additional setup after loading the view.
}

- (void)click:(NSNotification *)notification{
    NSLog(@"通知:%@",notification.object);
}

#pragma mark-- 设置界面
- (void)setupUI{
    [self.view addSubview:self.tabelV];
   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(titleButtonDidRepeatClick) name:@"TKYTitleButtonDidRepeatClickNotification" object:nil];

}

#pragma mark -- UITableViewDataSource, UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return kHeightScale *110;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TKYSafetyCell *cell = [tableView dequeueReusableCellWithIdentifier:KSafetyCellID];
    cell.startDateLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
    return cell;
}

- (BaseTabelView *)tabelV{
    if (_tabelV == nil) {
        _tabelV = [[BaseTabelView alloc]initWithFrame:CGRectMake(0, kHeightScale *35, kScreenWidth,kScreenHeight -MyNavBarHeight -kHeightScale *35 - kHeightScale *200) style:UITableViewStylePlain];
        _tabelV.dataSource = self;
        _tabelV.delegate = self;
        [_tabelV registerClass:[TKYSafetyCell class] forCellReuseIdentifier:KSafetyCellID];
        _tabelV.mj_header = [TKYRefreshHeader headerWithRefreshingBlock:^{
            
            
        }];
    }
    return _tabelV;
}


- (void)titleButtonDidRepeatClick{
    // 如果当前控制器的view不在window上，就直接返回,否则这个方法调用五次
    if (self.view.window == nil) return;
    
    // 如果当前控制器的view跟window没有重叠，就直接返回
    if (![self.view intersectWithView:self.view.window]) return;
    
    // 进行下拉刷新
    //[self.tableView.mj_header beginRefreshing];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
